clc
clear

CapacityTotal = 2;
CapacityList = 0:0.01:CapacityTotal;
SaltList = 0:0.01:CapacityTotal;

flowRate = 0.01;
timeMatrix = zeros(length(SaltList), length(CapacityList));

for ii = 1:length(SaltList)
    for jj = 1:length(CapacityList)
        if SaltList(ii) >= CapacityList(jj)
            timeMatrix(ii, jj) = inf;
            continue;
        end
        capacityA = CapacityList(jj);
        capacityB = CapacityTotal - capacityA;
        saltA = min(SaltList(ii), capacityA);
        saltB = max(SaltList(ii) - capacityA, 0);
        timeMatrix(ii, jj) = min(saltA/flowRate, (capacityB-saltB)/flowRate);
    end
end

figure;
imagesc(CapacityList, SaltList, timeMatrix);
colorbar;
xlabel('Capacity A');
ylabel('Salt A');
title('Time Heatmap');


